//
//  HERoomNoticeCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2021/3/1.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HERoomNoticeCell.h"

@interface HERoomNoticeCell ()

@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *descLb;
@property (nonatomic, strong) UILabel *timeLb;

@end

@implementation HERoomNoticeCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

- (void)initUI {
     
    _titleLb = [UILabel new];
    _titleLb.textColor = CNavLightBlackColor;
    _titleLb.font = DYBlodFont(18);
    _titleLb.numberOfLines = 0;
    [self.contentView addSubview:_titleLb];
 
    _descLb = [UILabel new];
    _descLb.textColor = CNavDargGrayColor;
    _descLb.font = DYFont(15);
    _descLb.numberOfLines = 0;
    [self.contentView addSubview:_descLb];
    
    _timeLb = [UILabel new];
    _timeLb.textColor = CNavDargGrayColor;
    _timeLb.font = DYFont(15);
    [self.contentView addSubview:_timeLb];
 
 
    [_timeLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

    [_timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];

    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.lessThanOrEqualTo(_timeLb.mas_left);
    }];
    [_titleLb setContentHuggingPriority:UILayoutPriorityRequired  forAxis:UILayoutConstraintAxisVertical];
 
    [_descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
}
 
- (void)setModel:(HERoomNotices *)model {
    _model = model;
    _titleLb.text = model.noticeName;
    _descLb.text = model.noticeContent;
    _timeLb.text = [NSDate timestampToDate:model.createDate formaterMode: NSDateFormaterModeDefault];
}

@end

